﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BUS;
using DTO;

namespace GUI
{
    public partial class frmThemPhanCong : Form
    {
        public frmThemPhanCong()
        {
            InitializeComponent();
        }

        private void frmThemPhanCong_Load(object sender, EventArgs e)
        {
            LoadComboboxMaNhanVien();
        }

        public void LoadComboboxMaNhanVien()
        {
            NhanVienBUS nvBUS = new NhanVienBUS();
            List<NhanVienDTO> listNV= new List<NhanVienDTO>();
            listNV = nvBUS.LayDanhSachNhanVien();
            this.cbMaNV.DataSource = listNV;
            this.cbMaNV.DisplayMember = "MaNV";
            cbMaNV.ValueMember = "MaNV";
            this.cbTenNV.DataSource = listNV;
            this.cbTenNV.DisplayMember = "TenNV";
            cbTenNV.ValueMember = "MaNV";
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            LichLamViecBUS llvBUS = new LichLamViecBUS();
            LichLamViecDTO llvDTO = new LichLamViecDTO();
            llvDTO.ThoiGianLamViec = TimeSpan.Parse(dtpThoiGianLV.Text);
            llvDTO.NgayLamViec = DateTime.Parse(this.dtpNgayLV.Text);
            int TTrang = 0;
            if (rdChuaLam.Checked == true)
                TTrang = 0;
            else TTrang = 1;
            llvDTO.TinhTrang = TTrang;
            llvDTO.MaNV = int.Parse(cbMaNV.SelectedValue.ToString());
            string kq = llvBUS.ThemLichlamViec(llvDTO);
            if (kq == "")
            {
                MessageBox.Show("Phân công nhân viên thành công!");
            }
            else MessageBox.Show(kq);
        }

        private void btnQuayRa_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
